package cn.xyfmzmy.eventloop;

/**
 * 可以指定EventLoop执行的Runnable
 */
public class TargetRunnable implements Runnable{

    // 指定EventLoop的下标
    private final int index;

    // 真正要执行的Runnable
    private final Runnable runnable;

    public TargetRunnable(int index, Runnable runnable) {
        this.index = index;
        this.runnable = runnable;
    }

    public int getIndex() {
        return index;
    }

    @Override
    public void run() {
        runnable.run();
    }
}
